home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8909 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  45 lines

  1. Path: news.mira.net.au!news
  2. From: davidw@werple.net.au (David White)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is there a standard for * and & placement style?
  5. Date: 27 Feb 1996 21:37:52 +1100
  6. Organization: Werple Internet, Melbourne
  7. Message-ID: <4gumu0$7c9@werple.net.au>
  8. References: <3128BD31.4AF8@wildfire.com> <marnoldDn27q9.Is0@netcom.com> <4gckd5$bc7@clarknet.clark.net> <marnoldDn63vB.H6n@netcom.com> <4gk1b8$mtm@werple.net.au> <marnoldDn9u0A.GAD@netcom.com>
  9. NNTP-Posting-Host: werple.mira.net.au
  10.  
  11. marnold@netcom.com (Matt Arnold) writes:
  12.  
  13.  
  14. >...is a "special case" for the "char *"-style, simply highlights that the
  15. >style, IMO, is conceptually inconsistent.  Certainly, the function itself 
  16. >doens't have pointer-ness (although, as for as the language it concerned, it 
  17. >resovles to an expression that does) and so it doesn't seem quite right to 
  18. >associate the * with the function name.  It seems inconsistent that you 
  19. >would make this concession, but turn around and insist the "char *p" makes 
  20. >sense for the declaration of p.
  21.  
  22. It wasn't a concession. I would use 'char *foo()'. I was just saying that
  23. I can understand why some people prefer 'char* foo()' (and 'char* p').
  24.  
  25. I don't want to drag this on, because it doesn't bother me if others use
  26. the 'char* p' form, but I don't think my point came across too well.
  27. My main point concerned you and another poster suggesting that the form:
  28.     char* p, q;
  29. should declare both 'p' and 'q' to be char*. I was just trying to demonstrate
  30. that, without making special rules for '*' (and '&'), this doesn't fit in
  31. with the language. As far as the compiler is concerned, *, &, [],
  32. () are operators that apply to an operand. In its parsing, it treats
  33. them that way whether it is an expression or a declaration. It is only
  34. because '*' happens to be a pre-operand operator that you are able
  35. to place the '*' with the 'char'. That's why I prefer the 'char *p'
  36. (and 'char *foo()') form; I just follow the same rules as the compiler
  37. for everything. I don't see any fundamental difference between
  38. 'array of char' and 'pointer to char'; arrays and pointers are both
  39. types derived from some other, but you can't write 'char[10] p', simply
  40. because the [10] is on the wrong side of 'p'.
  41.  
  42. David White
  43. davidw@werple.mira.net.au
  44.  
  45.